package cn.funnyxb.powerremember.uis.task.done.autobrow;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

public class AutoBrowConfiger
{
  public static String[] ACTIONNAMES = null;
  public static final int ACTION_SHOW_MEANING = 5;
  public static final int ACTION_SHOW_PHONETIC = 4;
  public static final int ACTION_SHOW_SENTENCES = 6;
  public static final int ACTION_SHOW_WORD = 3;
  public static final int ACTION_SPEECH_CHAR = 8;
  public static final int ACTION_SPEECH_WORD = 7;
  public static final int ACTION_WAIT1S = 1;
  public static final int ACTION_WAIT1SHALF = 2;
  private static final String SharedPreferencesName = "autobrow";
  private static AutoBrowConfiger config;
  private static final String defaultActions = "72415261831111";
  private static final int defaultSpeechTimesWhenHandMode = 2;
  public final int ACTION_MAX = 8;
  public final int ACTION_MIN = 1;
  private String actions;
  private boolean autoQueryOnline;
  private int autoSpeechTimesWhenHandmode;
  private Context context;
  private ArrayList<Integer> difficultys;
  private String key_AutoSpeechTimesWhenHandmode = "autospeechtimes_when_handmode";
  private String key_SpeechOnclickWhenHandmode = "speech_onClick_when_handmode";
  private String key_actions = "actions";
  private String key_autoQueryOnline = "autoqueryonline";
  private String key_difficulty = "key_autobrow_difficulty";
  private boolean speechOnClickWhenHandMode = true;
  private TaskQuene taskQuene;

  private AutoBrowConfiger(Context paramContext)
  {
    this.context = paramContext;
    if (ACTIONNAMES == null)
      ACTIONNAMES = paramContext.getResources().getStringArray(2130968579);
    log("context create=" + paramContext);
    loadConfig();
  }

  private boolean checkRangeValid(int paramInt)
  {
    if ((paramInt >= 1) && (paramInt <= 8));
    for (int i = 1; ; i = 0)
      return i;
  }

  public static AutoBrowConfiger getConfig(Context paramContext)
  {
    if (config == null)
      config = new AutoBrowConfiger(paramContext);
    return config;
  }

  private void loadConfig()
  {
    log("context=" + this.context);
    SharedPreferences localSharedPreferences = this.context.getSharedPreferences("autobrow", 0);
    this.actions = localSharedPreferences.getString(this.key_actions, "72415261831111");
    TaskQuene localTaskQuene = parseActionQuene(this.actions);
    log("parse in loadConfig,quene=" + localTaskQuene);
    if (localTaskQuene == null)
    {
      log("quene=" + localTaskQuene);
      saveActions("72415261831111");
    }
    while (true)
    {
      this.autoQueryOnline = localSharedPreferences.getBoolean(this.key_autoQueryOnline, true);
      this.autoSpeechTimesWhenHandmode = localSharedPreferences.getInt(this.key_AutoSpeechTimesWhenHandmode, 2);
      this.speechOnClickWhenHandMode = localSharedPreferences.getBoolean(this.key_SpeechOnclickWhenHandmode, true);
      this.difficultys = readDifficultys();
      return;
      this.taskQuene = localTaskQuene;
    }
  }

  private static void log(String paramString)
  {
    Debuger.log("autobrowcfg", paramString);
  }

  private ArrayList<Integer> readDifficultys()
  {
    String str = this.context.getSharedPreferences("autobrow", 0).getString(this.key_difficulty, null);
    Object localObject;
    if ((str == null) || (str.trim().length() == 0))
    {
      localObject = null;
      return localObject;
    }
    ArrayList localArrayList = new ArrayList();
    char[] arrayOfChar = str.toCharArray();
    int i = arrayOfChar.length;
    for (int j = 0; ; ++j)
    {
      if (j >= i)
        localObject = localArrayList;
      localArrayList.add(Integer.valueOf(Integer.parseInt(arrayOfChar[j])));
    }
  }

  private void saveDifficultys(ArrayList<Integer> paramArrayList)
  {
    String str = "";
    Iterator localIterator;
    if ((paramArrayList != null) && (paramArrayList.size() != 0))
      localIterator = paramArrayList.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        this.context.getSharedPreferences("autobrow", 0).edit().putString(this.key_difficulty, str).commit();
        return;
      }
      int i = ((Integer)localIterator.next()).intValue();
      str = str + i;
    }
  }

  public String[] getActionNameArray()
  {
    return ACTIONNAMES;
  }

  public String getActions()
  {
    return this.actions;
  }

  public String getAllActionIntro()
  {
    return translateActionStr("12345678");
  }

  public int getAutoSpeechTimesWhenHandmode()
  {
    return this.autoSpeechTimesWhenHandmode;
  }

  public ArrayList<Integer> getDifficultys()
  {
    return this.difficultys;
  }

  public TaskQuene getTaskQueneCopy()
  {
    log("taskQuene=" + this.taskQuene);
    if (this.taskQuene == null);
    for (TaskQuene localTaskQuene = null; ; localTaskQuene = this.taskQuene.copyOne())
      return localTaskQuene;
  }

  public boolean isAutoQueryOnline()
  {
    return this.autoQueryOnline;
  }

  public boolean isSpeechOnClickWhenHandMode()
  {
    return this.speechOnClickWhenHandMode;
  }

  public TaskQuene parseActionQuene(String paramString)
  {
    Object localObject;
    if (paramString == null)
      localObject = null;
    while (true)
    {
      label7: return localObject;
      TaskQuene localTaskQuene = new TaskQuene();
      int i = paramString.length();
      log("length=" + i);
      CharSequence localCharSequence = paramString.subSequence(0, i);
      int j = 0;
      if (j >= i)
        localObject = localTaskQuene;
      char c = localCharSequence.charAt(j);
      try
      {
        int k = Integer.parseInt(Character.toString(c));
        if (!(checkRangeValid(k)))
          localObject = null;
        localTaskQuene.input(k);
        log("input value=" + k);
        ++j;
      }
      catch (Exception localException)
      {
        log("exception in parseConfig,e=" + localException.getMessage());
        localObject = null;
        break label7:
      }
    }
  }

  public boolean saveActions(String paramString)
  {
    TaskQuene localTaskQuene = parseActionQuene(paramString);
    if (localTaskQuene == null);
    for (int i = 0; ; i = 1)
    {
      return i;
      this.actions = paramString;
      this.taskQuene = localTaskQuene;
      this.context.getSharedPreferences("autobrow", 0).edit().putString(this.key_actions, paramString).commit();
    }
  }

  public void setActions(String paramString)
  {
    this.actions = paramString;
  }

  public void setAutoQueryOnline(boolean paramBoolean)
  {
    this.context.getSharedPreferences("autobrow", 0).edit().putBoolean(this.key_autoQueryOnline, paramBoolean).commit();
    this.autoQueryOnline = paramBoolean;
  }

  public void setAutoSpeechTimesWhenHandmode(int paramInt)
  {
    if (paramInt < 0);
    while (true)
    {
      return;
      this.autoSpeechTimesWhenHandmode = paramInt;
      this.context.getSharedPreferences("autobrow", 0).edit().putInt(this.key_AutoSpeechTimesWhenHandmode, paramInt).commit();
    }
  }

  public void setDifficultys(ArrayList<Integer> paramArrayList)
  {
    if ((paramArrayList == null) || (paramArrayList.size() == 0) || (paramArrayList.size() == 10));
    while (true)
    {
      return;
      this.difficultys = paramArrayList;
      saveDifficultys(paramArrayList);
    }
  }

  public void setSpeechOnClickWhenHandmode(boolean paramBoolean)
  {
    this.speechOnClickWhenHandMode = paramBoolean;
    this.context.getSharedPreferences("autobrow", 0).edit().putBoolean(this.key_SpeechOnclickWhenHandmode, paramBoolean);
  }

  public String translateActionStr(String paramString)
  {
    int i = paramString.length();
    CharSequence localCharSequence = paramString.subSequence(0, i);
    Object localObject1 = "";
    int j = 0;
    while (true)
    {
      Object localObject2;
      if (j >= i)
      {
        localObject2 = localObject1;
        label29: return localObject2;
      }
      char c = localCharSequence.charAt(j);
      try
      {
        int k = Integer.parseInt(Character.toString(c));
        if (!(checkRangeValid(k)))
          localObject2 = null;
        String str = localObject1 + k + "->" + ACTIONNAMES[k] + "\n";
        localObject1 = str;
        ++j;
      }
      catch (Exception localException)
      {
        localObject2 = null;
        break label29:
      }
    }
  }

  public static class TaskQuene
  {
    private Boolean existShowSentenceTaskWhenAutoBrow = null;
    private LinkedList<Integer> list = new LinkedList();

    public TaskQuene copyOne()
    {
      TaskQuene localTaskQuene = new TaskQuene();
      localTaskQuene.list = ((LinkedList)this.list.clone());
      return localTaskQuene;
    }

    public Integer getHead()
    {
      AutoBrowConfiger.access$0("quene size=" + this.list.size());
      return ((Integer)this.list.poll());
    }

    public boolean hasNext()
    {
      if (this.list.size() > 0);
      for (int i = 1; ; i = 0)
        return i;
    }

    public void input(int paramInt)
    {
      this.list.addLast(Integer.valueOf(paramInt));
    }

    public boolean isExistShowSentenceTaskWhenAutoBrow()
    {
      if (this.existShowSentenceTaskWhenAutoBrow == null)
        this.existShowSentenceTaskWhenAutoBrow = Boolean.valueOf(isExistTask(6));
      return this.existShowSentenceTaskWhenAutoBrow.booleanValue();
    }

    public boolean isExistTask(int paramInt)
    {
      return this.list.contains(Integer.valueOf(paramInt));
    }
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.done.autobrow.AutoBrowConfiger
 * JD-Core Version:    0.5.3
 */